package com.bll;

import java.util.ArrayList;

import com.dal.SeverityDAO;
import com.model.Severity;

public class SeverityBLO {
	public enum SeverityEnum {
		Coding(1), Syntax(2);

		private final int id;

		SeverityEnum(int i) {
			id = i;
		}

		SeverityEnum parse(int i) throws Exception {
			for (SeverityEnum e : SeverityEnum.values()) {
				if (e.id == id) {
					return e;
				}
			}
			return null;
		}
	}

	private int severityId;
	private String severityName;

	public SeverityBLO(int SeverityId, String SeverityName) {
		super();
		this.severityId = SeverityId;
		this.severityName = SeverityName;
	}

	// Methods

	public static ArrayList<SeverityBLO> loadAllSeverity() {
		ArrayList<Severity> list = new SeverityDAO().select();
		return getSeverityBLOListFromEntityList(list);
	}

	// Internal Methods
	private  static ArrayList<SeverityBLO> getSeverityBLOListFromEntityList(
			ArrayList<Severity> list) {
		ArrayList<SeverityBLO> SeverityBLOlist = new ArrayList<SeverityBLO>();
		for (Severity Severity : list) {
			SeverityBLOlist.add(getSeverityBLOFromEntity(Severity));
		}
		return SeverityBLOlist;
	}

	private static SeverityBLO getSeverityBLOFromEntity(Severity entity) {
		return new SeverityBLO(entity.getSeverityID(), entity.getSeverityName());
	}

	// Utility Methods
	public String getDisplayText() {
		return severityName;
	}

	/**
	 * @return the SeverityId
	 */
	public int getSeverityId() {
		return severityId;
	}

	/**
	 * @param SeverityId
	 *            the SeverityId to set
	 */
	public void setSeverityId(int SeverityId) {
		this.severityId = SeverityId;
	}

	/**
	 * @return the SeverityName
	 */
	public String getSeverityName() {
		return severityName;
	}

	/**
	 * @param SeverityName
	 *            the SeverityName to set
	 */
	public void setSeverityName(String SeverityName) {
		this.severityName = SeverityName;
	}

}
